package com.jyx.designpatterns.policy;

public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		SuperMan cjns = new SuperMan();
		// 使用策略1
		cjns.setStrategy(new StrategyOne());
		Person liyuchun = new Person();
		liyuchun.setName("李宇春");
		double [] a = {9.12,9.25,8.87,9.99,6.99,7.88};
		
		
		Person zhangliangying = new Person();
		zhangliangying.setName("张靓颖");
		double [] b = {9.15,9.26,8.97,9.89,6.97,7.89};
		
		
		liyuchun.setScore(cjns.getPersonScore(a));
		zhangliangying.setScore(cjns.getPersonScore(b));
		System.out.println("使用算术平均值方案：");
		System.out.printf("%s 最后得分：%5.3f%n",liyuchun.getName(),liyuchun.getScore());
		System.out.printf("%s 最后得分：%5.3f%n",zhangliangying.getName(),zhangliangying.getScore());
		
		//使用第二种策略
		cjns.setStrategy(new StrategyTwo());
		liyuchun.setScore(cjns.getPersonScore(a));
		zhangliangying.setScore(cjns.getPersonScore(b));
		System.out.println("使用几何平均值方案：");
		System.out.printf("%s 最后得分：%5.3f%n",liyuchun.getName(),liyuchun.getScore());
		System.out.printf("%s 最后得分：%5.3f%n",zhangliangying.getName(),zhangliangying.getScore());
		
		//使用第三种策略
		cjns.setStrategy(new StrategyThree());
		liyuchun.setScore(cjns.getPersonScore(a));
		zhangliangying.setScore(cjns.getPersonScore(b));
		System.out.println("使用(去掉最高、最低)算术平均值方案：");
		System.out.printf("%s 最后得分：%5.3f%n",liyuchun.getName(),liyuchun.getScore());
		System.out.printf("%s 最后得分：%5.3f%n",zhangliangying.getName(),zhangliangying.getScore());
	}

}
